package com.bawei.a2010kotlin

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import com.bawei.a2010kotlin.room.AppDataBase
import com.bawei.a2010kotlin.room.AppDataBase_Impl
import com.bawei.a2010kotlin.room.Student

/**
 Lifecycle：感知activity/fragment/service/application
 ViewModel：
 LiveData：
 DataBinding：
 Room：
 WorkManager：




 */
class MainActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        var studentDao = AppDataBase.getAppDataBase()?.getStudentDao()
        var student1 = Student(1,"张三1",34)
        var student2 = Student(2,"张三2",34)
        var student3 = Student(3,"张三3",34)
        studentDao?.insert(student1)
        studentDao?.insert(student2)
        studentDao?.insert(student3)

        println(studentDao?.select())
        student1.name = "里斯"
        studentDao?.update(student1)
        println(studentDao?.select())

        studentDao?.delete(student1)
        println(studentDao?.select())


    }
}